package com.xyh.transaction.service.imp;

import com.xyh.transaction.common.Current;
import com.xyh.transaction.entity.Message;
import com.xyh.transaction.mapper.MessageMapper;
import com.xyh.transaction.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class MessageServiceImpl implements MessageService {

    @Autowired
    private MessageMapper messageMapper;


    @Override
    public List<Message> getMessageList() {
        Message message = new Message();
        message.setUserId(Current.getCurrentUser().getUser().getId());

        return messageMapper.findAll(message);
    }

    @Override
    public void updateMessage(Message message) {
        message.setUpdateBy(Current.getCurrentUser().getUser().getId());
        message.setUpdateTime(LocalDateTime.now());
        messageMapper.update(message);
    }

}
